<style scoped>
  .uploader-btn {
    width: 30px;
    height: 30px;
    padding: 0 !important;
    border: 0 !important;
  }
</style>
<template>
  <uploader :options="options" @file-success="finishUpload" @file-progress="progress">
      <uploader-unsupport></uploader-unsupport>
      <uploader-btn></uploader-btn>
  </uploader>
</template>
<script>

  export default {
    name: 'UploadFile2',
    data() {
      return {
        options: {
          target: '/fileUpload/upload.action',
          // target: '/system/Tuser!getWxUser.action',
          // singleFile: true,
          chunkSize: "1048576" * 6,
          // chunkSize: '1480000000',   //分块大小
          testChunks: false,     //是否开启服务器分片校验
        }
      }
    },
    props: [
      'orderid'
    ],
    mounted() {
      if (this.orderid) {
        this.options.target = '/fileUpload/upload.action?orderid=' + this.orderid;
      }
    },
    methods: {
      emitter (event, data) {
        this.$emit(event, data)
      },
      finishUpload(rootFile, file, response, chunk) {
        $.hideLoading()

        let res = JSON.parse(response);
        if (res.msg == 'success') {
          let thisfile = {
            name: file.name,
            id: res.fileid
          }
          this.emitter('pushfile', thisfile);
        }
      },
      progress(rootFile, file, chunk) {
        $.showLoading("上传中")
        // this.toastText5(`上传中 ${file.name}，chunk：${chunk.startByte / 1024 / 1024} ~ ${chunk.endByte / 1024 / 1024}`)
      }
    }
  }
</script>

